<?php
/**
 * Created by PhpStorm.
 * User: xieky
 * Date: 2018/2/12
 * Time: 16:06
 */

namespace common\repositories\myhtsq;

use common\repositories\BaseRepository;
use common\entities\myhtsq\ContractBackAmountEntity;

class ContractBackAmountRepository extends BaseRepository
{
    /**
     * 构造方法
     * @param unknown $config (optional)
     */
    public function __construct($config = [])
    {
        parent::__construct($config);
    }

    public static function getBackAmountListByContractid($contractId){
        $sql = "SELECT ba.*,bu.BUName area_name,IF(ba.is_received_invoce=1,'是','否') is_received_invoce_code
                FROM myscrm_contract_back_amount ba
                left join myscrm_erp_business_unit bu on ba.area_id=bu.BUGUID
                where ba.contract_id='".$contractId."'";

        $list = ContractBackAmountEntity::getDb()->createCommand($sql)->queryAll();
        return $list;
    }
}